#[allow(warnings, unused)]
mod prisma;

use prisma::PrismaClient;
use prisma_client_rust::NewClientError;

use tokio;
use crate::prisma::user;

#[tokio::main]
async fn main() {
    let client: Result<PrismaClient, NewClientError> = PrismaClient::_builder().build().await;

    let mut client = client.unwrap();

    client.user().create("1".to_string(), "Xu Jiajun".to_string(),
    vec![
        // user::display_name::set("Yang Yan".to_string())
    ]).exec().await.unwrap();

    client.user().create("2".to_string(), "Xu Jiajun1".to_string(),
                         vec![
                             // user::display_name::set("Yang Yan".to_string())
                         ]).exec().await.unwrap();


    let users: Vec<user::Data> = client
        .user()
        .find_many(vec![user::id::equals("1".to_string())])
        .exec()
        .await
        .unwrap();
    println!("users created: {:?}", users);

    let updated_person: user::Data = client
        .user()
        .update(
            user::id::equals("2".to_string()),
            vec![user::display_name::set("I'm Xjj, too".to_string())]
        )
        .exec()
        .await
        .unwrap();
    println!("user updated: {:?}", updated_person);

    let deleted_person: user::Data = client
        .user()
        .delete(user::id::equals("1".to_string()))
        .exec()
        .await
        .unwrap();

    println!("deleted user: {:?}", deleted_person);

    let users: Vec<user::Data> = client
        .user()
        .find_many(Vec::new())
        .exec()
        .await
        .unwrap();
    println!("users left: {:?}", users);
}
